﻿namespace TestApp.Tests
{
    using Contracts;
    using DataService;
    using Microsoft.Reactive.Testing;
    using NUnit.Framework;
    using Shouldly;

    [TestFixture]
    internal class DataRandomizerFixture
    {
        private TestScheduler _scheduler;

        [SetUp]
        public void SetUp()
        {
            _scheduler = new TestScheduler();
            _scheduler.CreateObserver<EntityDto>();
        }

        [Test, Repeat(100)]
        public void ShouldGenerateIndexInRange0To19()
        {
            // Given
            var target = CreateInstance();

            // When
            var index = target.GenerateIndex();

            // Then
            index.ShouldBeGreaterThanOrEqualTo(0);
            index.ShouldBeLessThanOrEqualTo(19);
        }

        [Test, Repeat(100)]
        public void ShouldGenerateParameterValueInRangeNeg1To1()
        {
            // Given
            var target = CreateInstance();

            // When
            var parameterValue = target.GenerateParameterValue();

            // Then
            parameterValue.ShouldBeGreaterThanOrEqualTo(-1d);
            parameterValue.ShouldBeLessThanOrEqualTo(1d);
        }

        private IDataRandomizer CreateInstance()
        {
            return new DataRandomizer();
        }
    }
}
